inspector: Go to the right tab when changing objects
authorMatthias Clasen <mclasen@redhat.com>
Sat, 31 May 2014 03:21:13 +0000 (23:21 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 31 May 2014 03:22:29 +0000 (23:22 -0400)
When going from attribute mapping to model, it makes most sense
to go directly to the data tab, and when going from an action
name to the owner, we want to show the actions tab. Make it so.

gtk/inspector/prop-editor.c
gtk/inspector/prop-editor.h
gtk/inspector/prop-list.c
gtk/inspector/window.c

index 213592d464b503f782f1c5c7f3205b676d8c85d6..f49e7209a8c134f49c30eb09e10ec91fa2a48505 100644 (file)
@@ -642,7 +642,7 @@ object_properties (GtkInspectorPropEditor *editor)
 
   g_object_get (editor->priv->object, editor->priv->name, &obj, NULL);
   if (G_IS_OBJECT (obj))
-    g_signal_emit (editor, signals[SHOW_OBJECT], 0, obj, editor->priv->name);
+    g_signal_emit (editor, signals[SHOW_OBJECT], 0, obj, editor->priv->name, "properties");
 }
 
 static void
@@ -1092,7 +1092,7 @@ model_properties (GtkButton              *button,
   GObject *model;
 
   model = g_object_get_data (G_OBJECT (button), "model");
-  g_signal_emit (editor, signals[SHOW_OBJECT], 0, model, "model");
+  g_signal_emit (editor, signals[SHOW_OBJECT], 0, model, "model", "data");
 }
 
 static void
@@ -1258,7 +1258,7 @@ show_action_owner (GtkButton              *button,
   GObject *owner;
 
   owner = g_object_get_data (G_OBJECT (button), "owner");
-  g_signal_emit (editor, signals[SHOW_OBJECT], 0, owner, NULL);
+  g_signal_emit (editor, signals[SHOW_OBJECT], 0, owner, NULL, "actions");
 }
 
 static GtkWidget *
@@ -1404,7 +1404,7 @@ gtk_inspector_prop_editor_class_init (GtkInspectorPropEditorClass *klass)
                   G_SIGNAL_RUN_LAST,
                   G_STRUCT_OFFSET (GtkInspectorPropEditorClass, show_object),
                   NULL, NULL, NULL,
-                  G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_STRING);
+                  G_TYPE_NONE, 3, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_STRING);
 
   g_object_class_install_property (object_class, PROP_OBJECT,
       g_param_spec_object ("object", "Object", "The object owning the property",
index 8febf33baba27eca0de53fb5664fec8523fe1d90..6fef2319b45edffd799c666f1682acfbd73e2e80 100644 (file)
@@ -41,7 +41,10 @@ typedef struct
 {
   GtkBoxClass parent;
 
-  void (*show_object) (GtkInspectorPropEditor *editor, GObject *object, const gchar *name);
+  void (*show_object) (GtkInspectorPropEditor *editor,
+                       GObject                *object,
+                       const gchar            *name,
+                       const gchar            *tab);
 } GtkInspectorPropEditorClass;
 
 
index 7eb03751e483ada64ac21d3d351dc3966c27dbd7..9d3b8d8b148a984d531d8c4642d5567415dd4c7f 100644 (file)
@@ -123,6 +123,7 @@ static void
 show_object (GtkInspectorPropEditor *editor,
              GObject                *object,
              const gchar            *name,
+             const gchar            *tab,
              GtkInspectorPropList   *pl)
 {
   GtkTreeIter iter;
@@ -131,6 +132,7 @@ show_object (GtkInspectorPropEditor *editor,
   popover = gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_POPOVER);
   gtk_widget_hide (popover);
 
+  g_object_set_data (G_OBJECT (pl->priv->widget_tree), "next-tab", (gpointer)tab);
   if (gtk_inspector_widget_tree_find_object (pl->priv->widget_tree, object, &iter))
     {
       gtk_inspector_widget_tree_select_object (pl->priv->widget_tree, object);
index 72d1aad308ea0cedd741f15ed39acc71ec6ef2d8..cc3b36a5036f63c3126630c60754e9f72d27a33f 100644 (file)
@@ -62,6 +62,9 @@ on_widget_tree_selection_changed (GtkInspectorWidgetTree *wt,
                                   GtkInspectorWindow     *iw)
 {
   GObject *selected = gtk_inspector_widget_tree_get_selected_object (wt);
+  GtkWidget *notebook;
+  const gchar *tab;
+  gint page_num;
 
   if (!gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->prop_list), selected))
     return;
@@ -77,6 +80,24 @@ on_widget_tree_selection_changed (GtkInspectorWidgetTree *wt,
   gtk_inspector_actions_set_object (GTK_INSPECTOR_ACTIONS (iw->actions), selected);
   gtk_inspector_gestures_set_object (GTK_INSPECTOR_GESTURES (iw->gestures), selected);
 
+  notebook = gtk_widget_get_parent (iw->prop_list);
+  tab = g_object_get_data (G_OBJECT (iw), "next-tab");
+  if (g_strcmp0 (tab, "properties") == 0)
+    {
+      page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), iw->prop_list);
+      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
+    }
+  else if (g_strcmp0 (tab, "data") == 0)
+    {
+      page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), iw->data_list);
+      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
+    }
+  else if (g_strcmp0 (tab, "actions") == 0)
+    {
+      page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), iw->actions);
+      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
+    }
+
   if (GTK_IS_WIDGET (selected))
     gtk_inspector_flash_widget (iw, GTK_WIDGET (selected));
 }